312131ca5a8c5ddb49f5f57b98edd3682cff0acc,app/src/processing/app/Editor.java,Editor,checkModified,#,2145
Before Change
JOptionPane.QUESTION_MESSAGE);
if (result == JOptionPane.YES_OPTION) {
return handleSave(true);
} else if (result == JOptionPane.NO_OPTION) {
return true; // ok to continue
After Change
JOptionPane.QUESTION_MESSAGE);
if (result == JOptionPane.YES_OPTION) {
ret = handleSave(true);
} else if (result == JOptionPane.NO_OPTION) {
ret = true; // ok to continue
} else if (result == JOptionPane.CANCEL_OPTION
|| result == JOptionPane.CLOSED_OPTION) {
ret = false;
} else {
throw new IllegalStateException();
}
} else {
// This code is disabled unless Java 1.5 is being used on Mac OS X
// because of a Java bug that prevents the initial value of the
// dialog from being set properly (at least on my MacBook Pro).
// The bug causes the "Don't Save" option to be the highlighted,
// blinking, default. This sucks. But I'll tell you what doesn't
// suck--workarounds for the Mac and Apple's snobby attitude about it!
// I think it's nifty that they treat their developers like dirt.
// Pane formatting adapted from the quaqua guide
// http://www.randelshofer.ch/quaqua/guide/joptionpane.html
JOptionPane pane = new JOptionPane("<html> "
+ "<head> <style type=\"text/css\">"
+ "b { font: 13pt \"Lucida Grande\" }"
+ "p { font: 11pt \"Lucida Grande\"; margin-top: 8px }"
+ "</style> </head>"
+ "<b>Do you want to save changes to this sketch<BR>"
+ " before closing?</b>"
+ "<p>If you don't save, your changes will be lost.",
JOptionPane.QUESTION_MESSAGE);
String[] options = new String[] { "Save", "Cancel", "Don't Save" };
pane.setOptions(options);
// highlight the safest option ala apple hig
pane.setInitialValue(options[0]);
// on macosx, setting the destructive property places this option
// away from the others at the lefthand side
pane.putClientProperty("Quaqua.OptionPane.destructiveOption",
new Integer(2));
JDialog dialog = pane.createDialog(this, null);
dialog.setVisible(true);
Object result = pane.getValue();
if (result == options[0]) { // save (and close/quit)
ret = handleSave(true);
} else if (result == options[2]) { // don't save (still close/quit)
ret = true;
} else { // cancel?
ret = false;
}
}
if (ret) {
//the sketch is closing
stopReloadThread = true;
}
return ret;
}
/**